<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="umsroot.css">
<TITLE>
Precompiled (ECO) Files
</TITLE>
</HEAD>
<BODY >
<A HREF="umsroot032.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot028.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot034.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc73">6.5</A>&nbsp;&nbsp;Precompiled (ECO) Files</H2><UL>
<LI><A HREF="umsroot033.html#toc42">Making Precompiled Files</A>
<LI><A HREF="umsroot033.html#toc43">Restrictions</A>
<LI><A HREF="umsroot033.html#toc44">Loading Precompiled Files</A>
<LI><A HREF="umsroot033.html#toc45">Using the Compiler with a Makefile</A>
</UL>


<A NAME="toc42"></A>
<H3 CLASS="subsection"><A NAME="htoc74">6.5.1</A>&nbsp;&nbsp;Making Precompiled Files</H3>
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> source files can be compiled into ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> object files,
<A NAME="@default243"></A>
for subsequent loading. These files have the <B>.eco</B> suffix
by default.
This facility is mainly intended for module files.
To create such a file, call the compiler with the
appropriate output-option, e.g.
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
?- compile(myprogram, [output:eco]).
</PRE></BLOCKQUOTE>
This create a precompiled file myprogram.eco from a source file called
myprogram.ecl (or myprogram.pl). If the source file contained
include directives, the result will be a single object file containing
the compiled code of all included files.
In earlier releases of ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> this was done using the
<A HREF="../bips/lib/fcompile/fcompile-1.html"><B>fcompile/1</B></A><A NAME="@default244"></A>
predicate from the fcompile library,
which is still supported for compatibility.<BR>
<BR>
Loading of ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> object files is significantly faster than compilation
from source. In ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> 6.0, ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> object files are text files
containing a representation of the compiled abstract machine code, and
can be used to deploy application code without revealing the source.
The precompiled code is hardware and operating system independent.
It may however not be portable between different versions of ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>
if details of the abstract machine were modified between releases.<BR>
<BR>
The file suffix used for ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> object files is the value of the
global flag <B>eclipse_object_suffix</B><A NAME="@default245"></A>.<BR>
<BR>
<A NAME="toc43"></A>
<H3 CLASS="subsection"><A NAME="htoc75">6.5.2</A>&nbsp;&nbsp;Restrictions</H3>
Currently, the compiler generates the auxiliary predicates for the do
iterator using a module-wide counter to name the predicates. Unfortunately this
means that if an object file with auxiliary predicates is loaded into a
module that already has existing code that contains auxiliary predicates, 
naming conflict can occur and the old auxiliaries may be replaced. It is
thus strongly recommended that object files should not be loaded into an
existing module. This will only be a problem if the file does not contain
any module declarations that redefines the module (i.e. <A HREF="../bips/kernel/modules/module-1.html"><B>module/1</B></A><A NAME="@default246"></A>),
as these redefinition will erase the old copy of
the module.<BR>
<BR>
One restriction does apply between platforms of different
word sizes: integers which fit in the word size of one platform
but not the other are represented differently internally in ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>. 
Specifically, integers which takes between 32 and 64
bits to represent are treated as normal integers on a 64 bit machine,
but as bignums (see section&nbsp;<A HREF="umsroot044.html#intrep">8.2.1</A>) on 32 bit machines. This
difference is normally invisible, but if
such numbers occur as constants in the program code (i.e. their values appear
textually), they can lead to different low-level compiled abstract code on
the different platforms. Avoid using such constants if you want
the object code to be portable across different word sizes (they can always
be computed at run-time, e.g. writing <CODE>2^34</CODE> instead of <TT>17179869184</TT>).<BR>
<BR>
<A NAME="toc44"></A>
<H3 CLASS="subsection"><A NAME="htoc76">6.5.3</A>&nbsp;&nbsp;Loading Precompiled Files</H3>
The following predicates either invoke the compiler or load precompiled .eco files.
If the source specification does not specify the file type, precompiled files
are preferred if they can be found in the search path:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<A HREF="../bips/kernel/compiler/D-2.html"><B>[File1,...,FileN]</B></A><A NAME="@default247"></A><DD CLASS="dd-description">
<A NAME="@default248"></A>
This predicate can be used as a shorthand for the <B>compile</B> predicate,
usually in the interactive toplevel.
It accepts a list of files, which can be source files or precompiled files.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/compiler/ensure_loaded-1.html"><B>ensure_loaded(Files)</B></A><A NAME="@default249"></A><DD CLASS="dd-description">
<A NAME="@default250"></A>
This predicate compiles the specified file if it has not been compiled
yet or if it has been modified since the last compilation.
It can be used to load application code or system libraries.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/modules/use_module-1.html"><B>use_module(Files)</B></A><A NAME="@default251"></A><DD CLASS="dd-description">
<A NAME="@default252"></A>
A combination of ensure_loaded/1 and import/1.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/compiler/lib-1.html"><B>lib(Lib)</B></A><A NAME="@default253"></A><DD CLASS="dd-description">
<A NAME="@default254"></A>
This predicate is used to ensure that a specified library file is loaded.
It is equivalent to ensure_loaded(library(Lib)).
If this library is not yet compiled or loaded, the system will look
in all directories in the <TT>library_path</TT> flag for a file with this name,
which is either a source file or a precompiled file, and compile or load it.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/env/make-0.html"><B>make</B></A><A NAME="@default255"></A><DD CLASS="dd-description">
<A NAME="@default256"></A>
This predicate recompiles or reloads all files that have been modified
since their last compilation or loading.
</DL>
To implement reloading/recompiling when needed, the system keeps track of
when a particular source files was compiled or precompiled file was loaded
into memory. This information can be accessed explicitly through
<A HREF="../bips/kernel/compiler/current_compiled_file-3.html"><B>current_compiled_file/3</B></A><A NAME="@default257"></A>.<BR>
<BR>
<A NAME="toc45"></A>
<H3 CLASS="subsection"><A NAME="htoc77">6.5.4</A>&nbsp;&nbsp;Using the Compiler with a Makefile</H3>

To generate .eco file from source files, the compiler can be run from the
command line using the -e option.
To invoke it from a makefile, use the following suffix rule
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
.SUFFIXES:  $(SUFFIXES) .ecl .eco
.ecl.eco:
        eclipse -e "compile(\"$&lt;\",[output:eco])"
</PRE></BLOCKQUOTE>
or a pattern rule for Gnu make:
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
%.eco:  %.ecl
        eclipse -e "compile(\"$&lt;\",[output:eco])"
</PRE></BLOCKQUOTE>
<HR>
<A HREF="umsroot032.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot028.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot034.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
